<template>
	<view class="wrap">
		<u-cell-group :border="false" title="消息提醒">
			<u-cell-item title="接受消息提醒" :arrow="false">
				<u-switch v-model="message" slot="right-icon" class="u-m-l-20"></u-switch>
			</u-cell-item>
			<u-cell-item title="通知栏显示消息详情" :arrow="false">
				<u-switch v-model="messageBar" slot="right-icon" class="u-m-l-20"></u-switch>
				<text slot="label">关闭后，当收到消息的时候，只显示有提示，不显示消息内容。</text>
			</u-cell-item>
		</u-cell-group>
		<u-cell-group :border="false" title="声音与振动">
			<u-cell-item title="收到消息后播放声音或振动" @click="openSettings">
				<text slot="label">前往系统设置中，修改声音与振动</text>
			</u-cell-item>
		</u-cell-group>
		<u-cell-group :border="false" title="软件更新提醒">
			<u-cell-item title="软件更新提醒" :arrow="false">
				<u-switch v-model="upgrade" slot="right-icon" class="u-m-l-20"></u-switch>
				<text slot="label">当本软件有新版本发布时，给予提醒</text>
			</u-cell-item>
			<u-cell-item title="版本号" :arrow="false" click="changeDatabase" >
				<!-- <u-switch v-model="upgrade" slot="right-icon" class="u-m-l-20"></u-switch> -->
				<text slot="label">1.8.5</text>
			</u-cell-item>
		</u-cell-group>
		
		<!-- {{uuid}} -->
	</view>
</template>
<script>
	let begin=0;
	/**
	 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
	 */
	export default {
		data() {
			return {
				
				uuid:'te',
				message: true,
				messageBar: true,
				upgrade: true
			};
		},
		created() {
			this.getuuid()
		},
		methods: {
			changeDatabase(){
				
			},
			getuuid() {
				let _this= this
				console.log(' ' );
				// #ifdef APP-PLUS
				plus.device.getInfo({
					success: (e) => {
						console.log('getDeviceInfo success: ' + JSON.stringify(e));
						_this.uuid = e.uuid;
					},
					fail: (e) => {
						console.log('getDeviceInfo failed: ' + JSON.stringify(e));
							uni.showModal({
								title: '提示',
								content: '获取设备信息失败，是否授权打开设备信息',
								success: (res) => {
									if (res.confirm) {
										uni.getSystemInfo({
											success: (sys) => {
												if (sys.platform == 'ios') {
													plus.runtime.openURL("app-settings://");
												} else {
													var Intent = plus.android.importClass("android.content.Intent");
													var Settings = plus.android.importClass("android.provider.Settings");
													var Uri = plus.android.importClass("android.net.Uri");
													var mainActivity = plus.android.runtimeMainActivity();
													var intent = new Intent();
													var intentGoApp = new Intent(mainActivity.getIntent());
													var uri = Uri.fromParts("package", "应用包名", null);
													intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
													intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
													intent.setData(Uri.fromParts("package","写你自己的应用包名",null));
													mainActivity.startActivity(intent)
															}
														}
													})
												}
											}
										})
									}
								});
				// #endif
			},
			openSettings() {
				// #ifdef APP-PLUS
				uni.getSystemInfo({
					success(res) {
						if (res.platform == 'ios') {
							plus.runtime.openURL("app-settings://");
						} else if (res.platform == 'android') {
							var main = plus.android.runtimeMainActivity();
							var Intent = plus.android.importClass("android.content.Intent");
							var mIntent = new Intent('android.settings.SOUND_SETTINGS');
							main.startActivity(mIntent);
						}
					}
				});
				// #endif
				// #ifndef APP-PLUS
				this.$u.toast('小程序端或H5端已是最新版，无需检查更新！');
				// #endif
			},
			logout() {
				this.$u.api.logout().then(res => {
					this.$u.toast(res.msg);
					if (res.code == '200') {
						let self = this;
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/sys/login/index'
							});
						}, 500);
					}
				});
			}
		}
	};
</script>
<style lang="scss">
	page {
		background-color: #f8f8f8;
	}

	/deep/ .u-cell-title {
		padding: 25rpx 30rpx;
		font-size: 30rpx;
	}
</style>